package com.hex.ds.hdrs.common.helper;

import com.hex.ds.hdrs.period.job.po.PeriodJob;
import com.hex.ds.hdrs.period.task.po.PeriodTask;
import lombok.extern.slf4j.Slf4j;

import java.util.Map;

@Slf4j
public class MapHelper {

    /**
     * 比较内存和DB查出来的作业的 业务日期有差异的数据
     *
     * @param srcJobMap
     * @param targetJobMap
     */
    public static void compareJobMap(Map<String, PeriodJob> srcJobMap, Map<String, PeriodJob> targetJobMap) {
        log.debug("比较内存和DB查出来的作业的 业务日期 有差异的数据【MapHelper.compareJobMap】开始========》");
        for (Map.Entry<String, PeriodJob> targetJobEntry : targetJobMap.entrySet()) {
            PeriodJob targetJob = targetJobEntry.getValue();
            PeriodJob srcJob = srcJobMap.get(targetJobEntry.getKey());
            if (!targetJob.getBizDate().equals(srcJob.getBizDate())) {
                log.debug("【MapHelper.compareJobMap】===DB》==={}===《===",targetJob.toString());
                log.debug("【MapHelper.compareJobMap】===内存》==={}===《===",targetJob.toString());
            }
        }
        log.debug("【MapHelper.compareJobMap】结束《========");
    }

    /**
     * 比较内存和DB查出来的任务的 业务日期有差异的数据
     *
     * @param srcTaskMap
     * @param targetTaskMap
     */
    public static void compareTaskMap(Map<String, PeriodTask> srcTaskMap, Map<String, PeriodTask> targetTaskMap) {
        log.debug("比较内存和DB查出来的任务的 业务日期 有差异的数据【MapHelper.compareTaskMap】开始========》");
        for (Map.Entry<String, PeriodTask> targetJobEntry : targetTaskMap.entrySet()) {
            PeriodTask targetTask = targetJobEntry.getValue();
            PeriodTask srcTask = srcTaskMap.get(targetJobEntry.getKey());
            if (!targetTask.getBizDate().equals(srcTask.getBizDate())) {
                log.debug("【MapHelper.compareTaskMap】===DB》==={}===《===",targetTask.toString());
                log.debug("【MapHelper.compareTaskMap】===内存》==={}===《===",targetTask.toString());
            }
        }
    }
}
